package com.ds.infrastructure.hyperspace.console.model.response.handler;

import com.ds.infrastructure.hyperspace.console.entity.table.TbHandler;
import com.ds.infrastructure.hyperspace.console.model.request.handler.HandlerParamsForm;
import com.ds.infrastructure.hyperspace.console.utils.FastJsonUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author: yaozhendong
 * @create: 2019-09-20 19:47
 **/
@Data
@NoArgsConstructor
public class GetHandlerVO {

    private Long id;

    private String handlerName;

    private Integer handlerType;

    private List<HandlerParamsForm> handlerParams;
    @ApiModelProperty(value = "描述说明", example = "")
    private String description;
    @ApiModelProperty(value = "示例", example = "")
    private String example;

    public static GetHandlerVO toVO(TbHandler entity) {
        GetHandlerVO getHandlerVO = new GetHandlerVO();
        getHandlerVO.setId(entity.getId());
        getHandlerVO.setHandlerName(entity.getHandlerName());
        getHandlerVO.setHandlerType(entity.getHandlerType());
        getHandlerVO.setHandlerParams(FastJsonUtil.deserializeList(entity.getHandlerParams(), HandlerParamsForm.class));
        getHandlerVO.setDescription(entity.getDescription());
        getHandlerVO.setExample(entity.getExample());
        return getHandlerVO;
    }
}
